package com.wld.blacklist.dao.result;

import com.wld.blacklist.common.enums.CodeEnum;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;


@Data
@Slf4j
public class ResultVo {
    /**
     * 状态码
     */
    private Integer resultCode;
    /**
     * 操作信息
     */
    private String resultMessage;
    /**
     * 回参数据
     */
    private Object data1;
    private Object data2;

    private long count;


    public ResultVo(CodeEnum codeEnum) {
        this.resultCode = codeEnum.getCode();
        this.resultMessage = codeEnum.getDesc();
    }

    public ResultVo(CodeEnum codeEnum, Object data) {
        this.resultCode = codeEnum.getCode();
        this.resultMessage = codeEnum.getDesc();
        this.data1 = data;
    }

    public ResultVo(Integer resultCode, String msg, Object data) {
        this.resultCode = resultCode;
        this.resultMessage = msg;
        this.data1 = data;
    }
    public ResultVo(Integer resultCode, String msg, Object data,long count) {
        this.resultCode = resultCode;
        this.resultMessage = msg;
        this.data1 = data;
        this.count = count;
    }
    public ResultVo(CodeEnum codeEnum, Object data1,Object data2){
        this.resultCode = codeEnum.getCode();
        this.resultMessage =  codeEnum.getDesc();
        this.data1 = data1;
        this.data2 = data2;
    }

    public static ResultVo success() {
        ResultVo resultType = new ResultVo(CodeEnum.SUCCESS);
        log.info("处理成功：{}", resultType);
        return resultType;
    }
    public static ResultVo success(CodeEnum codeEnum, Object data) {
        ResultVo resultType = new ResultVo(codeEnum, data);
        log.info("处理成功：{}", resultType);
        return resultType;
    }
    public static ResultVo success(CodeEnum codeEnum, Object data, long count){
        ResultVo resultType = new ResultVo(codeEnum.getCode(), codeEnum.getDesc(),data,count);
        log.info("处理成功：{}", resultType);
        return resultType;
    }

    public static ResultVo success(CodeEnum codeEnum, Object data1,Object data2){
        ResultVo resultType = new ResultVo(codeEnum, data1,data2);
        log.info("处理成功：{}", resultType);
        return resultType;
    }

    public static ResultVo success(Object data) {
        ResultVo resultType = new ResultVo(CodeEnum.SUCCESS, data);
        log.info("处理成功：{}", resultType);
        return resultType;
    }

    public static ResultVo failed() {
        ResultVo resultType = new ResultVo(CodeEnum.SYS_ERROR);
        log.info("处理失败：{}", resultType);
        return resultType;
    }

    public static ResultVo failed(CodeEnum codeEnum) {
        ResultVo resultType = new ResultVo(codeEnum);
        log.info("处理失败：{}", resultType);
        return resultType;
    }

    public static ResultVo failed(CodeEnum codeEnum, Object data) {
        ResultVo resultType = new ResultVo(codeEnum, data);
        log.info("处理失败：{}", resultType);
        return resultType;
    }
}
